<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\modules\home\models\Category */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => '分类列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-view">

    <p>
        <?= Html::a('编辑', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'cid',
            'title',
            'code',
            'sort',
            'icon',
            // 'count',
            [
                'format' => 'raw',
                'attribute' => 'is_top_show',
                'value' => function($model) {
                    if($model->is_top_show == 1){
                        return '<span class="btn btn-xs btn-success">显示</span>';
                    }else{
                        return '<span class="btn btn-xs btn-danger">不显示</span>';
                    }
                },
            ],
            [
                'format' => 'raw',
                'attribute' => 'is_footer_show',
                'value' => function($model) {
                    if($model->is_footer_show == 1){
                        return '<span class="btn btn-xs btn-success">显示</span>';
                    }else{
                        return '<span class="btn btn-xs btn-danger">不显示</span>';
                    }
                },
            ],
            [
                'format' => 'raw',
                'attribute' => 'created_at',
                'value' => function($model) {
                    return date('Y-m-d H:i', $model->created_at);
                },
            ],
            [
                'format' => 'raw',
                'attribute' => 'updated_at',
                'value' => function($model) {
                    return date('Y-m-d H:i', $model->updated_at);
                },
            ],
        ],
    ]) ?>

</div>
